package ink.common;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static java.util.stream.Collectors.groupingBy;

/**
 * @author wangzhuangzhuang
 * @Description:
 * @date 2022-05-09 18:14
 */
public class LambdaGroupByTest {
	public static void main(String[] args) {
		List<Person> persons = new ArrayList<>();
		for (int i = 0; i < 20; i++) {
			Person person = new Person();
			person.setGrade(i + 10);
			person.setBoy(i % 2 == 0 ? "男" : "女");
			persons.add(person);
		}

		Map<String, List<Person>> collect = persons.stream()
				.collect(groupingBy(Person::isBoy));

		System.out.println(collect);
	}

}